import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
  state: {
    city: '北京'
  },
  actions: {
    // ctx调用对象 city传入对象
    changeCity(ctx, city) {
        console.log(city);
        ctx.commit('changeCity',city);//触发mutations
    }
  },
  mutations: {
    // state该state对象 city传入对象
    changeCity(state, city) {
        state.city = city;
    }
  }
})
